﻿using System;
using System.ComponentModel;
using System.Drawing;
using Microsoft.WowAddonStudio.FrameXml.Components.Events;
using Microsoft.WowAddonStudio.FrameXml.Components.Support;
using Microsoft.WowAddonStudio.FrameXml.Serialization;
using Microsoft.WowAddonStudio.FrameXml.Serialization.LayoutFrames;

namespace Microsoft.WowAddonStudio.FrameXml.Components
{
	[ToolboxBitmap(typeof(System.Windows.Forms.TextBox), "TextBox.bmp")]
	[ToolboxItemFilter("WowAddonStudio", ToolboxItemFilterType.Require)]
    [EventGroup(EventGroup.EditBox, EventName.OnTextChanged)]
    public class EditBoxControl : FrameControl
    {
		/// <summary>
		/// Initializes a new instance of the <see cref="EditBoxControl"/> class.
		/// </summary>
    	public EditBoxControl()
    	{
    	}

    	/// <summary>
        /// Initializes a new instance of the <see cref="EditBoxControl"/> class.
        /// </summary>
        /// <param name="editBox">The edit box.</param>
        public EditBoxControl(EditBox editBox)
            : base(editBox)
        {
        }

        /// <summary>
        /// Gets the edit box.
        /// </summary>
        public EditBox EditBox
        {
            get { return this.SerializationObject as EditBox; }
        }

        /// <summary>
        /// Gets the type of the serialization object this control manages.
        /// </summary>
        public override Type SerializationObjectType
        {
            get
            {
                return typeof(EditBox);
            }
        }

        /// <summary>
        /// Gets the default size of a FrameXML control.
        /// </summary>
        /// <value></value>
        protected override Size DefaultSize
        {
            get { return new Size(100, 32); }
        }

        /// <summary>
        /// Draws the FrameXML control.
        /// </summary>
        /// <param name="graphics">The <see cref="FrameXmlGraphics"/> context to draw to.</param>
        /// <param name="rectangle">The <see cref="Rectangle"/> to draw to.</param>
        /// <returns></returns>
        public override bool DrawControl(FrameXmlGraphics graphics, Rectangle rectangle)
        {
            base.DrawControl(graphics, rectangle);

            return EditBox.IsComplete;
        }
    }
}
